package com.wang.exam.service;

import com.wang.exam.mapper.AdminMapper;
import com.wang.exam.mapper.StudentMapper;
import com.wang.exam.mapper.TeacherMapper;
import com.wang.exam.pojo.Admin;
import com.wang.exam.pojo.Student;
import com.wang.exam.pojo.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class loginService {
    @Autowired
    AdminMapper adminMapper;
    @Autowired
    StudentMapper studentMapper;

    public List<Admin> getAdminList (String admin_name){
        List<Admin> adminList = adminMapper.getAdminByAdminName(admin_name);
        return adminList;
    }
    @Autowired
    TeacherMapper teacherMapper;

    public List<Teacher> getTeacherById(String teacher_id){
        List<Teacher> teacher = teacherMapper.getTeacherById(teacher_id);
        return teacher;
    }
    public List<Teacher> getTeacherList(int page,int rows){
        List<Teacher> teacherList = teacherMapper.getTeacherList((page-1)*rows,rows);
        return teacherList;
    }

    public List<Teacher> getTeacher(String keyword){
        List<Teacher> teachers = teacherMapper.getTeacher(keyword);
        return teachers;
    }

    public int getCount(){
        return teacherMapper.getCount();
    }

    public int deleteId(String [] ids){
        return teacherMapper.deleteId(ids);
    }

    public int addTeacher(Teacher teacher){
        return teacherMapper.addTeacher(teacher);
    }

    public int updateTeacher(String teacher_name,String teacher_pwd,String teacher_id){
        return teacherMapper.updateTeacher(teacher_name,teacher_pwd,teacher_id);
    }
    public int deleteTeacher(String teacher_id){
        return teacherMapper.deleteTeacher(teacher_id);
    }



    public List<Student> getStudentById(Integer student_id){
        List<Student> student = studentMapper.getStudentById(student_id);
        return student;
    }
    public List<Student> getStudentList(int page,int rows){
        List<Student>  students = studentMapper.getStudentList((page-1)*rows,rows);
        return students;
    }

    public List<Student> getStudent(String keyword){
        List<Student> students = studentMapper.getStudent(keyword);
        return students;
    }

    public int getSCount(){
        return studentMapper.getCount();
    }

    public int deleteSId(String [] ids){
        return studentMapper.deleteId(ids);
    }

    public int addStudent(Student student){
        return studentMapper.addStudent(student);
    }

    public int updateStudent(Integer student_id,String student_name,String student_pwd,Integer major_id){
        return studentMapper.updateStudent(student_id,student_name,student_pwd,major_id);
    }
    public int deleteStudent(Integer student_id){
        return studentMapper.deleteStudent(student_id);
    }
}
